package com.cjy.common.utils.tag;

import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.components.TextField;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.Writer;

/**
 * 输入框标签bean，自定义标签格式要求
 * User: Administrator
 * Date: 13-12-14
 * Time: 上午11:05
 */
public class InputTagBean extends TextField
{
	private String placeholder;
    //是否可见
    private boolean visible;

    public InputTagBean(ValueStack stack, HttpServletRequest request, HttpServletResponse response)
    {
        super(stack, request, response);
    }

    @Override
    public boolean end(Writer writer, String body)
    {
        if (visible)
        {
            return super.end(writer, body);
        }
        return false;
    }

    @Override
    protected void evaluateExtraParams()
    {
        super.evaluateExtraParams();
        addParameter("placeholder", findString(placeholder));
    }

    public String getPlaceholder()
    {
        return placeholder;
    }


    public void setPlaceholder(String placeholder)
    {
        this.placeholder = placeholder;
    }

    public void setVisible(boolean visible)
    {
        this.visible = visible;
    }
}
